package com.wcar.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wcar.common.entity.FrontUser;
import com.wcar.common.util.OssUtil;
import com.wcar.common.vo.Result;
import com.wcar.store.service.EvaluateService;
import com.wcar.store.vo.EvaluateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.wcar.common.entity.StoreEvaluate;

import java.util.List;

/**
 * @BelongsProject: four-wcar-idea
 * @BelongsPackage: com.wcar.store.controller
 * @Author: 李睢康
 * @CreateTime: 2024-05-24  10:21
 */
@RestController
@RequestMapping("/store/evaluate")
public class EvaluateController {
    @Autowired
    private EvaluateService evaluateService;
    @PostMapping("/api/selectEvaluate")
    public Result<IPage> genAll(@RequestBody EvaluateVo evaluateVo) {
        return evaluateService.selectAll(evaluateVo);
    }
    @PostMapping("/api/selectAllCustomer")
    public Result<List<FrontUser>> getUserAll(){
        return  evaluateService.selectUserAll();
    }
    @PostMapping("/api/uploadFile")
    public Result<String> img(MultipartFile file){
        String s = OssUtil.uploadOss(file);
        return new Result<String>(200,"上传成功",s);
    }
    @PostMapping("/api/insertStoreEvaluate")
    public Result<String> insert(@RequestBody StoreEvaluate evaluate){

        return evaluateService.insert(evaluate);
    }
    @PostMapping("/api/updateStoreEvaluate")
    public Result<String> update(@RequestBody StoreEvaluate evaluate){
        return evaluateService.update(evaluate);
    }
    @GetMapping("/api/deleteByEvaluateId")
    public Result<Integer> delete(Integer evaluateId){
        return evaluateService.delete(evaluateId);
    }
    @PostMapping("/api/selectCommentsVoByStoreId")
    public Result<List<StoreEvaluate>> findComment(Integer storeId){
        return evaluateService.selectComment(storeId);
    }
    @PostMapping("/api/insertEvaluate")
    public Result<String> insertEvaluate(@RequestBody StoreEvaluate evaluate){
        return evaluateService.insertEvaluate(evaluate);
    }
}
